import CustomHook from './miniprogram_npm/spa-custom-hooks/index';


// app.ts
App<IAppOption>({
    globalData: {
        currentUser: undefined,
        currentReadUser: undefined,
        currentUserState: undefined,
        access: undefined,
        isLogin: false,
        satoken: "",
    },
    onLaunch() {
        CustomHook.install({
            'CurrentUser': {
                name: 'CurrentUser',
                watchKey: 'currentUser',
                onUpdate(val: any) {
                    return !!val;
                }
            },
            'UserState': {
                name: 'UserState',
                watchKey: 'currentUserState',
                onUpdate(val: any) {
                    return !!val;
                }
            },
        }, this.globalData || 'globalData')
    },
    onShow(options) {
        console.log('app.ts getLaunchOptionsSync scene', wx.getLaunchOptionsSync().scene);
        // console.log('app.ts onShow', options);
        // console.log('app.ts onShow', options.query.shareAccountId);
        // console.log('app.ts onShow', this.globalData);
        // 存一下是否是阅读模式，有分享id，并且场景是1044就是阅读模式
        // this.globalData.isReader =  wx.getLaunchOptionsSync().scene && !!options.query?.shareAccountId;
        // this.globalData.isReader = !!options.query?.shareAccountId;// 存一下是否是阅读模式，有分享id就是阅读模式
        wx.login({
            success: res => {
                console.log('====readMode====',res.code);
                //判断是否是阅读器
                this.globalData.currentReadUser = {code: res.code};// 存一下当前阅读的用户信息
            },
        })
        const {windowWidth,windowHeight} = wx.getSystemInfoSync();
        this.globalData.windowWidth = windowWidth;
        this.globalData.windowHeight = windowHeight;
    },
})